package com.xiao.demo04;

import com.xiao.demo02.UserService;
import com.xiao.demo02.UserServiceImpl;

import java.lang.reflect.InvocationHandler;

public class Client {

    public static void main(String[] args) {
//        真实角色,必须要有
        UserServiceImpl userService = new UserServiceImpl();

//        代理角色，不存在

        ProxyInvocationHandler proxyInvocationHandler = new ProxyInvocationHandler();

        proxyInvocationHandler.setTarget(userService); //设置要代理的对象

//        动态生成代理类
        UserService proxy = (UserService) proxyInvocationHandler.getProxy();

        proxy.add();
        proxy.delete();


    }
}
